from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime, date
from app.models.project import ProjectStatus

class ProjectBase(BaseModel):
    customer_id: int
    room_number: str = Field(..., max_length=50)
    apartment_type: str = Field(..., max_length=10)
    notes: Optional[str] = None

class ProjectCreate(ProjectBase):
    contract_id: Optional[int] = None
    project_number: Optional[str] = None

class ProjectUpdate(BaseModel):
    room_number: Optional[str] = None
    apartment_type: Optional[str] = None
    contract_id: Optional[int] = None
    status: Optional[ProjectStatus] = None
    current_stage: Optional[str] = None
    start_date: Optional[date] = None
    completion_date: Optional[date] = None
    notes: Optional[str] = None

class ProjectResponse(ProjectBase):
    id: int
    contract_id: Optional[int] = None
    project_number: str
    status: ProjectStatus
    current_stage: Optional[str] = None
    start_date: Optional[date] = None
    completion_date: Optional[date] = None
    created_at: datetime
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True

